/**
  * 游戏配置文件
  * 存放游戏的配置数据
  * 比如：游戏界面尺寸、分享随机百分比、获取系统数据
  */
module GameConfig {
    //是不是微信浏览
    export function isWeiXin(): boolean {
        var ua = window.navigator.userAgent.toLowerCase();
        var microStr = "" + ua.match(/MicroMessenger/i);
        if (microStr == "null") {
            return false;
        } else if (microStr == "micromessenger") {
            return true;
        }
    }

    //是不是大屏
    export function isBigScreen(): boolean {
        return (document.body.clientHeight / document.body.clientWidth > 1.32);
    }

    //获得浏览器类型 pc android ios -- 可扩展为其他 如 微信、qqzone、qq、微博、校内、facebook
    export function systemType(): string {
        var ua = window.navigator.userAgent.toLowerCase();
        var microStr = "" + ua.match(/MicroMessenger/i);
        if (("" + ua.match(/windows nt/i)) == "windows nt") {
            return "windows";
        } else if (("" + ua.match(/iphone/i)) == "iphone") {
            return "ios";
        } else if (("" + ua.match(/android/i)) == "android") {
            return "android";
        } else if (("" + ua.match(/ipad/i)) == "ipad") {
            return "ipad";
        } else if (("" + ua.match(/linux/i)) == "linux") {
            return "linux";
        } else if (("" + ua.match(/mac/i)) == "mac") {
            return "mac";
        } else if (("" + ua.match(/ucbrower/i)) == "ucbrower") {
            return "ucbrower";
        } else {
            //console.log("未知系统类型");
        }
    }

    export function generateUUID() {
        var d = new Date().getTime();
        if (window.performance && typeof window.performance.now === "function") {
            d += performance.now(); //use high-precision timer if available
        }
        var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
            var r = (d + Math.random() * 16) % 16 | 0;
            d = Math.floor(d / 16);
            return (c == 'x' ? r : (r & 0x3 | 0x8)).toString(16);
        });
        return uuid;
    }


    //获得平台类型 如 微信、qqzone、qq、微博、校内、facebook
    export function platformType(): string {
        var ua = window.navigator.userAgent.toLowerCase();
        if (("" + ua.match(/micromessenger/i)) == "micromessenger") {
            return "micromessenger";
        } else if (("" + ua.match(/qzone/i)) == "qzone") {
            return "qzone";
        } else if (("" + ua.match(/weibo/i)) == "weibo") {
            return "weibo";
        } else if (("" + ua.match(/qq/i)) == "qq") {
            return "qq";
        } else if (("" + ua.match(/renren/i)) == "renren") {
            return "renren";
        } else if (("" + ua.match(/txmicroblog/i)) == "txmicroblog") {
            return "txmicroblog";
        } else if (("" + ua.match(/douban/i)) == "douban") {
            return "douban";
        } else {
            return "other";
        }
    }
    //当前游戏宽度
    export function curWidth(): number {
        return egret.MainContext.instance.stage.stageWidth;
    }

    //当前游戏宽度
    export function curHeight(): number {
        return egret.MainContext.instance.stage.stageHeight;
    }


}



